import axios from 'axios'
export const post = (url, data = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url,
      method: 'post',
      baseURL: 'http://dome.showpage.top:3000',
      data,
      headers: { 'Content-Type': 'application/json' },
      withCredentials: true
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}

export const get = (url, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url,
      params,
      method: 'get',
      withCredentials: true,
      baseURL: 'http://dome.showpage.top:3000'
    }).then(res => {
      resolve(res.data.data)
    }).catch(err => {
      reject(err)
    })
  })
}

export const getOrderData = (url, params = {}) => {
  return new Promise((resolve, reject) => {
    axios({
      url,
      params,
      method: 'get',
      baseURL: 'http://dome.showpage.top:3000'
    }).then(res => {
      resolve(res.data)
    }).catch(err => {
      reject(err)
    })
  })
}
